<template>
  <el-dialog title="评论列表" :visible.sync="visible" v-if="visible">
    <CommentTable :data-list="commentList" :page-info="pageInfo" :is-dialog="true" @currentChange="currentChange"
                  @sizeChange="sizeChange"/>
  </el-dialog>
</template>

<script>
import CommentTable from '@/components/CommentTable.vue'

export default {
  name: 'ArticleComment',
  components: { CommentTable },
  data () {
    return {
      visible: false,
      commentList: [],
      pageInfo: {
        page: 1,
        limit: 5,
        total: 0,
        articleId: '',
        status: 1
      }
    }
  },
  methods: {
    init (articleId) {
      this.visible = true
      this.pageInfo.articleId = articleId
      this.getCommentList()
    },
    getCommentList () {
      this.$http.get('admin/comment/page', this.pageInfo).then(data => {
        this.commentList = data.data.records
        this.pageInfo.page = data.data.current
        this.pageInfo.limit = data.data.size
        this.pageInfo.total = data.data.total
      })
    },
    currentChange (val) {
      this.pageInfo.page = val
      this.getCommentList()
    },
    sizeChange (val) {
      this.pageInfo.limit = val
      this.getCommentList()
    }
  }
}
</script>

<style scoped>

</style>
